/**   
* @Title: User.java 
* @Package com.csis.system.domain 
* @Description: TODO
* @author dailey  
* @date 2012-9-27
* @version V1.0   
*/
package com.csis.system.domain;

import static com.csis.system.common.IStaticData.COLUMN_USER_USERADDRESS;
import static com.csis.system.common.IStaticData.COLUMN_USER_USERID;
import static com.csis.system.common.IStaticData.COLUMN_USER_USERNAME;
import static com.csis.system.common.IStaticData.COLUMN_USER_USERNOTE;
import static com.csis.system.common.IStaticData.COLUMN_USER_USERPASSWORD;
import static com.csis.system.common.IStaticData.COLUMN_USER_USERPHONE;
import static com.csis.system.common.IStaticData.TABLE_USER;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import com.csis.security.domain.Role;
import com.csis.system.common.IStaticData;

/**
 * @author dailey
 *
 */
@Entity
@Table(name = TABLE_USER)
public class User {

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = COLUMN_USER_USERID)
	private java.lang.Integer id = null;
	@Column(name = COLUMN_USER_USERNAME)
	private java.lang.String userName = null;
	@Column(name = COLUMN_USER_USERPASSWORD)
	private java.lang.String userPassword = null;
	@Column(name = COLUMN_USER_USERPHONE)
	private java.lang.Long userPhone = null;
	@Column(name = COLUMN_USER_USERADDRESS)
	private java.lang.String userAddress = null;
	@Column(name = COLUMN_USER_USERNOTE)
	private java.lang.String userNote = null;

	@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.EAGER)
	@JoinTable(name = IStaticData.TABLE_ROLE_USER_MAP, inverseJoinColumns = @JoinColumn(name = IStaticData.COLUMN_ROLE_USER_MAP_ROLEID), joinColumns = @JoinColumn(name = IStaticData.COLUMN_ROLE_USER_MAP_USERID))
	@OrderBy("id")
	private Set<Role> roles = new LinkedHashSet<Role>();

	@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.EAGER)
	@JoinTable(name = IStaticData.TABLE_WARE_USER_MAP, inverseJoinColumns = @JoinColumn(name = IStaticData.COLUMN_WARE_USER_MAP_WAREID), joinColumns = @JoinColumn(name = IStaticData.COLUMN_WARE_USER_MAP_USERID))
	@OrderBy("id")
	private Set<Warehouse> wares = new LinkedHashSet<Warehouse>();

	/**
	 * @return the roles
	 */
	public Set<Role> getRoles() {
		return roles;
	}

	public java.lang.Integer getId() {
		return id;
	}

	public void setId(java.lang.Integer userId) {
		this.id = userId;
	}

	public java.lang.String getUserName() {
		return userName;
	}

	public void setUserName(java.lang.String userName) {
		this.userName = userName;
	}

	public java.lang.String getUserPassword() {
		return userPassword;
	}

	public void setUserPassword(java.lang.String userPassword) {
		this.userPassword = userPassword;
	}

	public java.lang.Long getUserPhone() {
		return userPhone;
	}

	public void setUserPhone(java.lang.Long userPhone) {
		this.userPhone = userPhone;
	}

	public java.lang.String getUserAddress() {
		return userAddress;
	}

	public void setUserAddress(java.lang.String userAddress) {
		this.userAddress = userAddress;
	}

	public java.lang.String getUserNote() {
		return userNote;
	}

	public void setUserNote(java.lang.String userNote) {
		this.userNote = userNote;
	}

	/**
	 * @return the wares
	 */
	public Set<Warehouse> getWares() {
		return wares;
	}

}
